/**
 * Created by kroyo on 2018/04/03
 * 专利详情  页面js
 */


$(function(){
	//1.‘编辑按钮’点击事件
    var $watch_view = $('.detailview'),
        $edit_view = $('.editview');
    $('.detailview .editbtn').on('click',function () {
        $watch_view.css('display','none');
        $edit_view.css('display','block');
    });
	
	
	//2.question-state
	var $question = $('.patent-insure .question'),
		$question_state = $('.patent-insure .question-state');
	$question.mouseover(function(e){
		$(this).parent().find('.question-state').fadeIn();
	});
	$question_state.mouseout(function(){
		$(this).fadeOut();
	});
	
	
	
	//3.check-warp
	$('.check-wrap input').change(function(){
		$(this).parent().toggleClass('checked');
	});
	

	//4.实体类型    视图切换
	$patenttype = $('.item-usertype input[name="imfor-type"]');
	if($patenttype.length > 0){
		changeView();
	}
	function changeView(){
		var $view_model = $('.editview .view-model');
		var val = null;
		// val   0 : 公司视图   ;   1: 个人视图
		$patenttype.change(function(){
			val = $(this).data('val');
			$view_model.eq(val).css('display','block');
	
			$patenttype.parent().removeClass('active');
			$(this).parent().addClass('active');
			
			
			//
			$('.editview input').css('border-color',' ');
			
	
			if(val==0){
				$view_model.eq(1).css('display','none');
			}else{
				$view_model.eq(0).css('display','none');
			}
		});
	}
	
	
	//4.1 视图初始化     off: true   ;   false : 
	function initView(off){
		var $view_computer = $('.editview .view-computer'),
			$view_person = $('.editview .view-person');
		if(off){
			$view_computer.css('display','block');
			$view_person.css('display','none');
		}else{
			$view_computer.css('display','none');
			$view_person.css('display','block');
		}
	}
	
	
	//计算状态显示情况
	var $status_middle = $('.status-middle');
	if($status_middle.length > 0){
		var $status_left = $status_middle.find('.view-left'),
			$status_right = $status_middle.find('.view-right');
		var width = $status_right.parent().width() - $status_right.width();
		$status_left.css('width',width);
		
		$status_right.parent().css('opacity','1');
	}
	
});
